package com.gogowan.agroenterprise.base;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import com.gogowan.agroenterprise.ActivityCollector;
import com.gogowan.agroenterprise.R;
import com.gogowan.agroenterprise.contorl.BMSApplication;
import com.gogowan.agroenterprise.contorl.RetrofitUtil.GsonUtil;
import com.gogowan.agroenterprise.contorl.RetrofitUtil.JSON_Tool;
import com.gogowan.agroenterprise.contorl.RetrofitUtil.MyRetrofit;
import com.gogowan.agroenterprise.idata.ScannerInterface;
import com.gogowan.agroenterprise.model.Message;
import com.gogowan.agroenterprise.utils.SystemBroadCast;
import com.gogowan.agroenterprise.utils.Utils;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.app.TimePickerDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.DatePicker;
import android.widget.TimePicker;
import android.widget.Toast;

import retrofit2.Call;
import retrofit2.Response;

import static com.gogowan.agroenterprise.utils.SystemBroadCast.SCN_CUST_ACTION_SCODE;
import static com.gogowan.agroenterprise.utils.SystemBroadCast.SCN_CUST_EX_SCODE;

/**
 * 所有类的基类,所有的类继承BaseActivity，这样可以实现跟踪
 * 
 * @author zhouke
 * 
 */
public class BaseActivity extends Activity {

	private boolean enableIData = true;
	// 是否是显示状态
	public boolean isVisible = false;
	/**
	 * 广播拦截器
	 */
	private InternalReceiver internalReceiver;
	private ScannerResultReceiver scannerResultReceiver;
	private AlertDialog mErrorDialog;
	private ScannerInterface scanner;
	private SystemBroadCast.ScanResultListener scanResultListener;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		// 将Activity放在list中
		ActivityCollector.addActivity(this);
		if (enableIData) {
			initIData();
		}
	}
	public void initScanView(SystemBroadCast.ScanResultListener scanResultListener){
		this.scanResultListener=scanResultListener;
		try{
			IntentFilter intentFilter = new IntentFilter(SCN_CUST_ACTION_SCODE);
			registerReceiver(scanDataReceiver,intentFilter);
		}catch (Exception e){
			e.printStackTrace();
		}

	}
	private BroadcastReceiver scanDataReceiver = new BroadcastReceiver() {
		@Override
		public void onReceive(Context context, Intent intent) {
			if(intent.getAction().equals(SCN_CUST_ACTION_SCODE)){
				try {
					if(scanResultListener!=null){
						String message = "";
						message = intent.getStringExtra(SCN_CUST_EX_SCODE).toString();
						scanResultListener.OnResult(message);
					}
				}catch (Exception e){
					e.printStackTrace();
					Log.e("in",e.toString());
				}


			}
		}
	};
	private void initIData() {
		scanner = new ScannerInterface(this);
		/**
		 * 设置扫描结果的输出模式，参数为0和1： 0为模拟输出，同时广播扫描数据（在光标停留的地方输出扫描结果同时广播扫描数据）;
		 * 1为广播输出（只广播扫描数据）； 2为模拟按键输出；
		 */
		scanner.setOutputMode(1);
		scanner.enablePlayVibrate(true);// 震动开启与关闭
	}

	/**
	 * 自定义应用全局广播处理器，方便全局拦截广播并进行分发
	 *
	 * @author 容联•云通讯
	 * @version 4.0
	 * @date 2014-12-4
	 */
	private class InternalReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context context, Intent intent) {
			if (intent == null || intent.getAction() == null) {
				return;
			}
			String resultStr = intent.getStringExtra(getString(R.string.DATA_STRING)).trim();
			if (resultStr.contains("s.idcode.org.cn")){
				return;
			}
			handleReceiver(context, intent);
		}
	}

	/**
	 * IDATA扫描结果广播接收
	 */
	private class ScannerResultReceiver extends BroadcastReceiver {
		public void onReceive(Context context, Intent intent) {
			if (intent == null || intent.getAction() == null) {
				return;
			}
			String scanResult_1 = GetScancode(intent);
			intent.putExtra("value",scanResult_1);
			intent.putExtra(getString(R.string.SCAN_STATE),scanResult_1);
			handleIDataReceiver(context, intent);
		}
	}

	/**
	 * 注册广播Action，子类如果需要监听广播可以调用 该方法传入相应事件的Action
	 *
	 actionArray
	 */
	protected final void registerReceiver(String[] actionArray) {
		if (actionArray == null) {
			return;
		}
		IntentFilter intentfilter = new IntentFilter();
		List<String> SCAN_ACTION=new ArrayList<>();
		SCAN_ACTION.add("nlscan.action.SCANNER_RESULT");
		SCAN_ACTION.add("android.intent.ACTION_DECODE_DATA");
		SCAN_ACTION.add("com.android.server.scannerservice.broadcast");
		SCAN_ACTION.add("android.intent.action.SCANRESULT");
		for (String action : SCAN_ACTION) {
			intentfilter.addAction(action);
		}
		if (internalReceiver == null) {
			internalReceiver = new InternalReceiver();
		}
		registerReceiver(internalReceiver, intentfilter);
	}
	public void startActivity(Class<?> cls){
		startActivity(new Intent(this,cls));
	}
	/**
	 * IDATA
	 *
	 actionArray
	 */
	protected final void registerIDataReceiver(String[] actionArray) {
		if (!enableIData) {
			return;
		}

		if (actionArray == null) {
			return;
		}
		IntentFilter intentfilter = new IntentFilter();
		List<String> SCAN_ACTION=new ArrayList<>();
		SCAN_ACTION.add("nlscan.action.SCANNER_RESULT");
		SCAN_ACTION.add("android.intent.ACTION_DECODE_DATA");
		SCAN_ACTION.add("com.android.server.scannerservice.broadcast");
		SCAN_ACTION.add("android.intent.action.SCANRESULT");
		for (String action : SCAN_ACTION) {
			intentfilter.addAction(action);
		}
		if (scannerResultReceiver == null) {
			scannerResultReceiver = new ScannerResultReceiver();
		}
		registerReceiver(scannerResultReceiver, intentfilter);
	}

	/**
	 * 如果子界面需要拦截处理注册的广播 需要实现该方法
	 *
	 context
	 intent
	 */
	protected void handleReceiver(Context context, Intent intent) {
		// 广播处理
		if (intent == null) {
			return;
		}
		String scanResult_1 = GetScancode(intent);
		if (scanResult_1.contains("https://s.idcode.org.cn/m?code=")){
			return;
		}
		if (!Utils.isEmpty(scanResult_1)) {
			intent.putExtra("value",scanResult_1);
			intent.putExtra(getString(R.string.SCAN_STATE),scanResult_1);
		} else {
			showToast( "扫码异常");

		}
	}
	private String GetScancode(Intent intent) {
		String ScanCode = intent.getStringExtra("SCAN_BARCODE1");
		if (Utils.isEmpty(ScanCode)) {
			ScanCode = intent.getStringExtra("scannerdata");
		}
		if (Utils.isEmpty(ScanCode)) {
			ScanCode = intent.getStringExtra("barcode_string");
		}
		if (Utils.isEmpty(ScanCode)) {
			ScanCode = "";
		}
		return ScanCode+"";
	}

	/**
	 * 如果子界面需要拦截处理注册的广播 需要实现该方法
	 *
	 context
	 intent
	 */
	protected void handleIDataReceiver(Context context, Intent intent) {
		// 广播处理
		if (intent == null) {
			return;
		}
		String scanResult_1 = GetScancode(intent);
		if (scanResult_1.contains("s.idcode.org.cn")){
			return;
		}
		if (!Utils.isEmpty(scanResult_1)) {
			intent.putExtra("value",scanResult_1);
			intent.putExtra(getString(R.string.SCAN_STATE),scanResult_1);

		} else {
			showToast( "扫码异常");
		}
	}

	/**
	 * 显示提示信息
	 *
	 toastStr
	 * @author Administrator
	 * @date 2017/11/29
	 */
	protected void showToast(String toastStr, int type) {
		if (type == 1) {
			mErrorDialog = new AlertDialog.Builder(this).setTitle("信息提示").setMessage(toastStr)
					.setNegativeButton("确定", new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							mErrorDialog.cancel();
						}
					}).create();
			mErrorDialog.show();
		} else {
			Toast.makeText(getApplicationContext(), toastStr, Toast.LENGTH_LONG).show();
		}
	}

	/**
	 * 结果类型
	 */
	public static final int RESULT_NOTHING = 2;
	public static final int RESULT_SUCCEED = 4;
	public static final int RESULT_FAILED = 8;

	/**
	 * 弹出框选中内容
	 */
	private String result = "";
	/**
	 * 状态
	 */
	private boolean state = false;

	public Handler handle = new Handler();

	public Handler getHandle() {
		return handle;
	}

	public void setHandle(Handler handle) {
		this.handle = handle;
	}

	// /**
	// * 异步类
	// */
	// private MyAsyncTask asyncTask=null;
	// /**
	// * 得到异步类
	// * @return 异步类
	// */
	// public MyAsyncTask getAsyncTask() {
	// return asyncTask;
	// }
	// /**
	// * 设置异步类
	// 异步类
	// */
	// public void setAsyncTask(MyAsyncTask asyncTask) {
	// this.asyncTask = asyncTask;
	// }
	/**
	 * 得到状态
	 * 
	 * @return 状态
	 */
	public boolean getState() {
		return state;
	}

	/**
	 * 设置状态
	 * 
	 状态
	 */
	public void setState(boolean state) {
		this.state = state;
	}

	/**
	 * 设置选中内容
	 * 
	 内容
	 */
	protected void setSelectedResult(String result) {
		this.result = result;
	}

	/**
	 * 得到选中内容
	 * 
	 * @return 内容
	 */
	protected String getSelectedResult() {
		return this.result;
	}

	/**
	 * 得到全局Application
	 * 
	 * @return 全局Application
	 */
	public BMSApplication getBMSApplication() {

		// Log.d("classtype", getApplication().getClass().toString());
		// return (BMSApplication)getApplicationContext();
		return (BMSApplication) getApplication();
	}

	/**
	 * 字符串转换成消息盒子
	 * 
	 results
	 *            返回的字符串
	 * @return message 消息盒子
	 */
	public Message stringToMessage(String results) {
		Message message = null;
		if (getState()) {
			return message;
		}
		if (results.equals("") || results == null) {
			return message;
		}
		message = Utils.jsonToMessage(results);// 转换成消息盒子
		return message;
	}

	/**
	 * 播放声音
	 */
	// public void PlaySound()
	// {
	// MediaPlayer mp = new MediaPlayer();
	// try {
	// AssetFileDescriptor file = getResources().openRawResourceFd(R.raw.sound);
	// mp.setDataSource(file.getFileDescriptor(), file.getStartOffset(),
	// file.getLength());
	// mp.prepare();
	// mp.start();
	// } catch (IOException e) {
	// }
	// }

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {

		// TODO Auto-generated method stub

		super.onActivityResult(requestCode, resultCode, data);

		if (requestCode == 1 && resultCode == RESULT_CANCELED) {

		}
		if (requestCode == 1 && resultCode == RESULT_NOTHING)
			;
		if (requestCode == 1 && resultCode == RESULT_SUCCEED) {
			this.setResult(RESULT_SUCCEED);
			this.finish();
		}
		if (requestCode == 1 && resultCode == RESULT_FAILED) {

		}

	}

	/**
	 * 确定弹出框
	 * 
	 标题
	 内容
	 */
	public void ShowDialog(String title, String content) {
		// 防止activity切换后,扔调用ShowDialog,出现异常.
		if (getState())
			return;
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle(title);
		builder.setMessage(content);
		builder.setCancelable(false);
		builder.setNegativeButton("确定", new OnClickListener() {
			public void onClick(DialogInterface dialog, int whichButton) {
				// do nothing
			}
		});

		builder.create().show();
	}

	/**
	 * 单选弹出框
	 * 
	 标题
	 内容
	 回调
	 * @return
	 */
	public void ShowDialog(String title, final String[] contents, final Callback callback) {
		AlertDialog.Builder builder = new AlertDialog.Builder(BaseActivity.this);
		builder.setTitle(title);
		builder.setItems(contents, new OnClickListener() {
			// public String selected;
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// setSelectedResult(contents[which]);
				// Handler handler=new Handler();
				android.os.Message msg = new android.os.Message();
				// msg.obj=which;
				Bundle bundle = new Bundle();
				bundle.putInt("token", which);
				// handler.sendMessage(msg);
				msg.setData(bundle);
				callback.handleMessage(msg);
			}
		});

		// handler.sendMessage(new Message().setData(new Bundle().putString("1",
		// "1")));
		// callback.handleMessage(new Message().obtain(new Ha));
		builder.show();
		// return getSelectedResult();
	}

	/**
	 * 单选弹出框
	 * 
	 标题
	 内容
	 回调
	 * @return
	 */
	public void ShowSingleChoiceDialog(String title, final String[] contents, final Callback callback) {
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle(title);
		builder.setSingleChoiceItems(contents, -1, new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int item) {
				setSelectedResult(contents[item]);
			}
		});
		builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				android.os.Message msg = new android.os.Message();

				Bundle bundle = new Bundle();
				bundle.putString("token", getSelectedResult());
				// handler.sendMessage(msg);
				msg.setData(bundle);
				callback.handleMessage(msg);
			}
		});
		builder.create().show();
	}

	/**
	 * 多选弹出框
	 * 
	 标题
	 内容
	 回调
	 * @return
	 */
	public void ShowMultiChoiceDialog(final String title, final String[] contents, final boolean[] selections,
			final Callback callback) {
		final AlertDialog.Builder builder = new AlertDialog.Builder(this);
		// final boolean selections[]=new boolean[contents.length];
		builder.setTitle(title);
		builder.setMultiChoiceItems(contents, selections, new OnMultiChoiceClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which, boolean isChecked) {
				// 点击选择
				// Log.i( "ME",options[ clicked ] + " selected: "
				// +selected );
			}
		});
		builder.setPositiveButton("确定", new OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				switch (which) {
				case DialogInterface.BUTTON_POSITIVE:
					String strs = "";
					for (int i = 0; i < contents.length; i++) {
						// Log.i( " ME", options[i ] + " selected: " +
						// selections[i] );
						if (selections[i]) {
							strs += contents[i] + "\n";
						}
					}
					android.os.Message msg = new android.os.Message();
					Bundle bundle = new Bundle();
					bundle.putString("token", strs);
					msg.setData(bundle);
					callback.handleMessage(msg);
					break;
				}
			}
		});
		builder.setNeutralButton("否", new OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				//
			}
		});
		builder.setNegativeButton("全选", new OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				int count = 0;
				for (int i = 0; i < selections.length; i++) {
					if (!selections[i]) {
						selections[i] = true;
					} else {
						count++;
					}
				}
				if (count == selections.length) {
					for (int i = 0; i < selections.length; i++) {
						selections[i] = false;
					}
				}
				builder.show();
			}
		});
		builder.create().show();
	}

	/**
	 * 弹出框
	 * 
	 标题
	 内容
	 Listener
	 * @return
	 */
	public void ShowDialog(String title, String content, OnClickListener callback) {
		if (getState())
			return;
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle(title);
		builder.setMessage(content);
		builder.setNegativeButton("确定", callback);
		builder.create().show();
	}

	/**
	 * 弹出框
	 * 
	 标题
	 内容
	 Listener
	 Listener
	 */
	public void ShowDialog(String title, String content, OnClickListener negativecallback,
			OnClickListener postcallback) {
		if (getState())
			return;
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle(title);
		builder.setMessage(content);
		builder.setPositiveButton("是", postcallback);
		builder.setNegativeButton("否", negativecallback);
		builder.create().show();
	}

	/**
	 * 弹出框
	 * 
	 标题
	 内容
	 Listener
	 Listener
	 */
	public void ShowDialog1(String title, String content, OnClickListener postcallback,
			OnClickListener negativecallback) {
		if (getState())
			return;
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle(title);
		builder.setMessage(content);
		builder.setPositiveButton("确定", postcallback);
		builder.setNegativeButton("取消", negativecallback);
		builder.create().show();
	}

	// public void SkipActivity(Context packageContext,boolean isfinished)
	// {
	// Intent intent = new Intent();
	// intent.setClass(packageContext,MainActivity.class);
	// startActivity(intent);
	// if(isfinished)
	// BaseActivity.this.finish();
	// }

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_HOME) // 主页键
		{
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	// public void onAttachedToWindow()
	// {
	// //屏蔽回主页
	// this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
	// super.onAttachedToWindow();
	// }

	@Override
	public void onStop() {
		setState(true);
		// MobclickAgent.onPause(this);
		// if(getAsyncTask()!=null)
		// getAsyncTask().Cancel();
		super.onStop();
	}

	@Override
	public void onResume() {
		setState(false);
		// MobclickAgent.onResume(this);
		super.onResume();
	}

	@Override
	public void onSaveInstanceState(Bundle savedInstanceState) {
		// Intent intent=new Intent();
		// intent.setClass(this, JSLoginActivity.class);
		// startActivity(intent);
		// this.finish();
		super.onSaveInstanceState(savedInstanceState);
	}

	/**
	 * 显示是否退出对话框
	 */
	protected void ShowExitDialog() {
		AlertDialog alert = new AlertDialog.Builder(this).setTitle("退出").setMessage("真的要退出了吗？")
				.setNegativeButton("否", new OnClickListener() {
					public void onClick(DialogInterface dialog, int whichButton) {
						// do nothing
					}
				}).setPositiveButton("是", new OnClickListener() {
					public void onClick(DialogInterface dialog, int whichButton) {
						// 结束应用程序
						android.os.Process.killProcess(android.os.Process.myPid());
					}
				}).create();
		alert.show();

	}

	protected void ShowExitActivityDialog(String message) {
		AlertDialog alert = new AlertDialog.Builder(this).setTitle("退出").setMessage(message)
				.setNegativeButton("否", new OnClickListener() {
					public void onClick(DialogInterface dialog, int whichButton) {
						// do nothing
					}
				}).setPositiveButton("是", new OnClickListener() {
					public void onClick(DialogInterface dialog, int whichButton) {
						BaseActivity.this.finish();
					}
				}).create();
		alert.show();

	}

	/**
	 * 日期选择框
	 * 
	 日期
	 callback
	 */
	public void ShowDateDialog(String date, final Callback callback) {
		int mYear, mMonth, mDay;
		Calendar c = Calendar.getInstance();
		date = Utils.getDateFormat(date, "yyyy-MM-dd");
		if (Utils.isEmpty(date)) {
			mYear = c.get(Calendar.YEAR);
			mMonth = c.get(Calendar.MONTH);
			mDay = c.get(Calendar.DAY_OF_MONTH);
		} else {
			int[] num = Utils.forNums(date);
			mYear = num[0];
			mMonth = num[1] - 1;
			mDay = num[2];
		}
		DatePickerDialog dp = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {

				android.os.Message msg = new android.os.Message();
				Bundle bundle = new Bundle();
				bundle.putString("token",
						year + "-" + Utils.formatTime(monthOfYear + 1) + "-" + Utils.formatTime(dayOfMonth));
				msg.setData(bundle);
				callback.handleMessage(msg);
			}
		}, mYear, mMonth, mDay);
		dp.show();
	}

	/**
	 * 弹出框
	 * 
	 标题
	 内容
	 positionContent
	 *            : 确定按钮上面要显示的内容
	 negativeContent
	 *            : 取消按钮上面要显示的内容
	 Listener
	 Listener
	 */
	public void ShowLogoutDialog(String title, String content, String positionContent, String negativeContent,
			OnClickListener negativecallback, OnClickListener postcallback) {
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle(title);
		builder.setMessage(content);
		builder.setPositiveButton(positionContent, postcallback);
		builder.setNegativeButton(negativeContent, negativecallback);
		builder.create().show();
	}

	/**
	 * 时间选择器
	 * 
	 time
	 callback
	 */
	public void ShowTimeDialog(String time, final Callback callback) {
		final int hour, minute;
		if (Utils.isEmpty(time)) {
			Calendar c = Calendar.getInstance();
			hour = c.get(Calendar.HOUR_OF_DAY);
			minute = c.get(Calendar.MINUTE);
		} else {
			int[] num = Utils.forTimeNums(time);
			hour = num[0];
			minute = num[1];
		}
		TimePickerDialog dp = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() {

			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				android.os.Message msg = new android.os.Message();
				Bundle bundle = new Bundle();
				bundle.putString("token", Utils.formatTime(hourOfDay) + ":" + Utils.formatTime(minute));
				msg.setData(bundle);
				callback.handleMessage(msg);
			}
		}, hour, minute, true);
		dp.show();
	}

	public void showToast(String message) {
		Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
	}

	public void closePicView() {

	}

	public void closeVedioView() {

	}

	public void hideView() {

	}

	public void showView() {

	}

	// 在onCreate()方法加入了就要删除
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		try{
			if (internalReceiver != null) {
				unregisterReceiver(internalReceiver);
			}
			try{
				if (scanDataReceiver != null) {
					unregisterReceiver(scanDataReceiver);
				}
			}catch (Exception e){
				e.printStackTrace();
			}
			if (scannerResultReceiver != null) {
				unregisterReceiver(scannerResultReceiver);
			}
			ActivityCollector.removeActivity(this);
		}catch (Exception e){
			e.printStackTrace();
		}
		super.onDestroy();

	}
	public void Http(Object o,String url, final ProgressDialog progressDialog, final RetrofitHttpListener listener){
		String jsonStr= GsonUtil.GsonString(o);
		MyRetrofit.init(this,getString(R.string.first_url)+url).
				Post1(new JSON_Tool.jsonPutBuild().getRetrofitReqBodyJson(jsonStr)).
				enqueue(new retrofit2.Callback<String>() {
			@Override
			public void onResponse(Call<String> call, Response<String> response) {
				progressDialog.cancel();
				if (!Utils.isEmpty(response.body())) {
					Message message = (Message) Utils.fromJSON(response.body(),
							Message.class);
					String string = Utils.getMessageContent(message);
					if (string == null || string.equals("")) {
						showToast(getString(R.string.analyse_error));
					} else {
						listener.OnJson(string);
					}
				} else {
					showToast(getString(R.string.Internet_JsonError));
				}
			}

			@Override
			public void onFailure(Call<String> call, Throwable t) {
				progressDialog.cancel();
				showToast(getString(R.string.Internet_Error));
			}
		});
	}
	public interface  RetrofitHttpListener{
		void OnJson(String str);
	}
}
